/**    
 * @{#} Role.java Create on Mar 23, 2012 12:05:45 AM    
 *    
 * Copyright (c) 2012 by 悠忧虫.    
 *    
 * @author   
 * @version 1.0    
 */
package tk.sunlatus.project.permission.domain;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;


/**
 * @{# Role.java Create on Mar 23, 2012 12:05:45 AM
 * 
 *     类功能说明:角色实体
 * 
 *     <p>
 *     Copyright: Copyright(c) 2012
 *     </p>
 * @Version 1.0
 * @author Sunlotus
 */
public class Role {
    
    //角色ID
    private String id;
    //角色名称
    private String name;
    //权限列表，暂定为String列表
    private Set<String> permissions;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the permission
     */
    public Set<String> getPermission() {
        return new HashSet<String>(permissions);
    }

    /**
     * 设置权限角色权限，如果权限非空则拒绝修改
     * 
     * @param permission
     *            the permission to set
     */
    public void setPermission(Set<String> permission) {
        if (this.permissions == null) {
            this.permissions = permission;
        }
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }
}
